package iscontinuous;

import java.util.TreeSet;

/**
 * 扑克牌顺子
 * @author lynn
 * @date 2020/10/24 - 11:17
 */
public class Solution {
    public boolean isContinuous(int[] numbers) {

        if (numbers.length != 5) {
            return false;
        }
        int count = 0;
        TreeSet<Integer> set = new TreeSet<>();
        for (int i = 0; i < numbers.length; i++) {
            if (numbers[i] == 0) {
                count++;
            } else {
                set.add(numbers[i]);
            }
        }
        if (count + set.size() != 5) {
            return false;
        }
        if (set.last() - set.first() >= 5) {
            return false;
        }
        return true;
    }
}
